Visual Basic (Declaration) | |
---|---|
Public Function Compare( _ ByVal x As KeyValuePair(Of TKey,TValue), _ ByVal y As KeyValuePair(Of TKey,TValue) _ ) As Integer |
C# | |
---|---|
public int Compare( KeyValuePair<TKey,TValue> x, KeyValuePair<TKey,TValue> y ) |
Parameters
- x
- y
Library/Library.Test/TestOrderedEnumeration.cs
C# | Copy Code |
---|---|
KeyValueComparer<int, int> cmp = new KeyValueComparer<int, int>(); Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, cmp.Comparer)); Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, KeyValueComparer<int, int>.Default.Comparer)); Assert.AreEqual(-1, cmp.Compare(new KeyValuePair<int, int>(1, 1), new KeyValuePair<int, int>(2, 1))); Assert.AreEqual(0, cmp.Compare(new KeyValuePair<int, int>(1, 1), new KeyValuePair<int, int>(1, 2))); Assert.AreEqual(1, cmp.Compare(new KeyValuePair<int, int>(2, 1), new KeyValuePair<int, int>(1, 1))); |
VB.NET | Copy Code |
---|---|
Dim cmp As New KeyValueComparer(Of Integer, Integer)() Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], cmp.Comparer)) Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], KeyValueComparer(Of Integer, Integer).[Default].Comparer)) Assert.AreEqual(-1, cmp.Compare(New KeyValuePair(Of Integer, Integer)(1, 1), New KeyValuePair(Of Integer, Integer)(2, 1))) Assert.AreEqual(0, cmp.Compare(New KeyValuePair(Of Integer, Integer)(1, 1), New KeyValuePair(Of Integer, Integer)(1, 2))) Assert.AreEqual(1, cmp.Compare(New KeyValuePair(Of Integer, Integer)(2, 1), New KeyValuePair(Of Integer, Integer)(1, 1))) |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7